/** 
* All Rights Reserved , Copyright (C) 2020 , 青岛鼎信通讯股份有限公司
* 
* PmIndexTabListServiceAuto
* 首页tab
* 
* 修改纪录
* 2020-05-18 版本：1.0 liwanpeng 创建。
* @version 版本：1.0
* @author 作者：liwanpeng
* 创建日期：2020-05-18
*/

package com.topscomm.pm.service.impl.auto;

import javax.annotation.Resource;
import com.topscomm.basic.IBasicDao;
import com.topscomm.cbo.pojo.CboDeptEntity;
import com.topscomm.cbo.pojo.CboRoleEntity;
import com.topscomm.cbo.pojo.CboUserEntity;
import com.topscomm.cbo.service.impl.CboDeptService;
import com.topscomm.cbo.service.impl.CboRoleService;
import com.topscomm.cbo.service.impl.CboUserRoleService;
import com.topscomm.cbo.service.impl.CboUserService;
import com.topscomm.tap.common.DatacodeCache;

import aj.org.objectweb.asm.Type;

import java.util.List;
import java.util.Map;
import com.topscomm.pm.*;
import com.topscomm.pm.pojo.PmIndexTabListEntity;
import com.topscomm.pm.service.impl.PmIndexTabListService;
import com.topscomm.pub.util.ConvertUtil;
import com.topscomm.pm.dao.IPmIndexTabListDao;


public class PmIndexTabListServiceAuto extends PmService<PmIndexTabListEntity,IPmIndexTabListDao> {
	@Resource
	private PmIndexTabListService pmIndexTabListService;
	@Resource
	private CboRoleService cboRoleService;
	@Resource
	private CboDeptService cboDeptService;
	@Resource
	private CboUserService cboUserService;
	/**
	 * @author: liwanpeng
	 * @date: 2020-05-18
	 * @param mapRow
	 * @description:设置字段显示值
	 * @modify:
	 */
	@Override
	public void setDispFields(Map<String, Object> mapRow, DatacodeCache datacodeCache) {
		String temp;
		if (mapRow.get("parentid") != null) {
			temp = mapRow.get("parentid").toString();
			mapRow.put("dispparentid", datacodeCache.getValueDynamic("code", temp, "id", "name"));
		}
		if (mapRow.get("type") != null) {
			temp = mapRow.get("type").toString();
			mapRow.put("disptype", datacodeCache.getValueDynamic("PmTabIsPermissionType", temp, "id", "name"));
		}
		if (mapRow.get("isopen") != null) {
			temp = mapRow.get("isopen").toString();
			mapRow.put("dispisopen", datacodeCache.getValueDynamic("PmTabIsOpen", temp, "code", "name"));
		}
		if (mapRow.get("enabled") != null) {
			temp = mapRow.get("enabled").toString();
			mapRow.put("dispenabled", datacodeCache.getValueDynamic("CboYesNo", temp, "code", "name"));
		}
		if (mapRow.get("applytocode") != null) {
			temp = mapRow.get("applytocode").toString();
			String type = ConvertUtil.convertToString(mapRow.get("type"));
			if (temp!=null) {
				if (type.equals("0")) {
					List<CboDeptEntity> queryByWhere = cboDeptService.queryByWhere("code = '"+temp+"'");
					mapRow.put("disapplytocode", queryByWhere.get(0).getName());
				}else if (temp.equals("1")) {
//					List<CboDeptEntity> queryByWhere = cboDeptService.queryByWhere("code = '"+temp+"'");
//					mapRow.put("disapplytocode", queryByWhere.get(0).getName());
				}else if (type.equals("2")) {
					List<CboRoleEntity> queryByWhere = cboRoleService.queryByWhere("code = '"+temp+"'");
					mapRow.put("disapplytocode", queryByWhere.get(0).getName());
				}else if (type.equals("3")) {
					List<CboUserEntity> queryByWhere = cboUserService.queryByWhere("code = '"+temp+"'");
					mapRow.put("disapplytocode", queryByWhere.get(0).getName());
				}
			}
		}
		if (mapRow.get("tabid") != null) {
			temp = mapRow.get("tabid").toString();
			if (temp!=null && !"".equals(temp)) {
				PmIndexTabListEntity queryById = pmIndexTabListService.queryById(temp);
				mapRow.put("distabid", queryById.getName());

			}
		}
	}

	@Override
	@Resource(name = "pmIndexTabListDao")
	public void setDao(IBasicDao<PmIndexTabListEntity> dao) {		
		super.setDao(dao);
	}
}
